Import SDK
Step 1:
- Copy DzoSDK-release.aar to folder
{Project}/app/libs
- Copy SDKConfig.json to folder
{Project}/app/src/main/assets
- Add to dependencies of build.grade(Module.app)
dependencies {
…
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
// --- DzoSDK Library --- //
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.android.volley:volley:1.2.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10'
implementation 'com.facebook.android:facebook-android-sdk:17.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-auth:21.2.0'
implementation "com.android.billingclient:billing:7.1.0"
implementation "com.android.installreferrer:installreferrer:2.2"
implementation 'com.appsflyer:af-android-sdk:6.5.0'
implementation 'com.google.android.play:review:2.0.1' // => Rating App
implementation platform('com.google.firebase:firebase-bom:33.6.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-dynamic-links'
implementation 'androidx.work:work-runtime:2.9.1'
// ------------------------- //
…
}
apply plugin: 'com.google.gms.google-services' // --- Add this at bottom ---
- Add to dependencies of build.grade(Project)
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0-alpha06'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.15' // google-services plugin
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
Step 2: Config Firebase
- Add a Firebase configuration file (Important)
- Move config file (google-services.json) into the module (app-level) directory of your app
({Project}/app/)
- Move config file (google-services.json) into the module (app-level) directory of your app
- In AndroidManifest, add these lines:
<application ...>
...
<service
android:name="vn.dzogame.library.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
...
</application>
Step 3:
- Config file strings.xml (as example) in folder
{Project}/app/src/main/res/values
<resources>
…
<string name="app_name">{YOUR_APPNAME}</string> <!-- Ex: Demo App -->
<string name="useDefaultButtonDzoHome">true</string>
<string name="useDefaultTag18Plus">true</string>
<string name="useDefaultBroadcast">true</string>
<string name="facebook_app_id">{YOUR FB APP ID}</string> <!-- Ex: 123456 -->
<string name="fb_login_protocol_scheme">fb{YOUR FB APP ID} </string> <!-- Ex: fb123456 -->
<string name="facebook_client_token">{YOUR FB CLIENT TOKEN} </string> <!-- Ex: 123456 -->
<string name="fb_ContentProvider">com.facebook.app.FacebookContentProvider{YOUR FB APP ID}</string> <!-- Ex: com.facebook.app.FacebookContentProvider123456-->
<string name="google_web_client_id">{YOUR GOOGLE WEB CLIENT ID}</string>
<string name="useAppsFlyerTracking">true</string>
<string name="AppsFlyer_DevKey">{AppsFlyer_DevKey}</string>
<string name="useFirebase">true</string>
<string name="useFirebaseTracking">true</string>
<string name="firebase_default_notification_channel_id">{BundleID}.urgent</string> <!-- Ex: com.test.app.urgent -->
...
</resources>
Step 4: (Activity lifecycle)
- Add code into function onActivityResult() in your Activity.
…
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(DzoSDK.TAG, "onActivityResult >>> requestCode:" + requestCode + " | resultCode: " + resultCode);
super.onActivityResult(requestCode, resultCode, data);
…
DzoSDK.GetInstance().OnActivityResult(requestCode, resultCode, data); // <== Add this code
}
…
Step 5:
- In Function onCreate() of Activity add this code to Init DzoSDK:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_login);
// ------ Init DzoSDK ------- //
if(!DzoSDK.GetInstance().IsConnected()){
DzoSDK.GetInstance().Init(this, new DzoInitCallback() {
@Override
public void OnInitSuccess() {
// --- Init Successful --- //
// … Your code … //
DzoSDK.GetInstance().Login(); // After Init SDK Successful, you can call Login.
}
@Override
public void OnLoginSuccess() { // Callback Login Successful, change NEXT SCENE
// --- Login Successful --- //
// => Init IAP Products and Dzovi Products
// … Your code … //
}
@Override
public void OnLogoutSuccess() { // Callback Logout Successful, you need to change LoginActivity
// --- Logout Successful --- //
// … Your code … //
}
@Override
public void OnDebugLog(boolean _isLogError, String _tag, String _msg) {
if (_isLogError){
Log.e(_tag, _msg);
}else {
Log.d(_tag, _msg);
}
}
});
} else {
DzoSDK.GetInstance().Login();
}
// -------------------------- //
// … Your code … //
}